﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Vincent._IO
{
    /// <summary>
    /// 文件操作类
    /// </summary>
    public class File
    {
        /// <summary>
        /// 遍历路径下的所有文件名
        /// </summary>
        /// <param name="FilePath"> 相对路径 </param>
        /// <returns> 文件名数组 </returns>
        public static string[] GetFileList(string FilePath)
        {
            String[] FileList = new String[10];

            if (!System.IO.Directory.Exists(FilePath))
            {
                System.IO.Directory.CreateDirectory(FilePath);
            }

            return FileList;
        }

        /// <summary>
        /// 创建某路径下的所有文件夹,如: D:/webpart/0101 检查是否有该文件夹,没有则新建
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static bool CreateDirectory(string path)
        {
            if (!Directory.Exists(Directory.GetDirectoryRoot(path)))
            {
                return false;
            }
            try
            {
                Directory.CreateDirectory(path);
                return true;
            }
            catch
            {
                return false;
            }
        }
    }

}
